package com.xxq.web;

import java.util.LinkedHashMap;
import java.util.Map;

import com.xxq.dao.Ad_loginDao;
import com.xxq.entity.Ad_Login;
import com.xxq.json.Jackson;

import my.mvc.RequestContext;
import my.util.ResponseUtils;

public class AdLoginAction {
	
	// ajax表单提交
	public void login(RequestContext rc) throws Exception {
		Ad_loginDao aLoginDao = new Ad_loginDao();
		String uname = rc.param("loignname");
		String passwd = rc.param("password");
		Ad_Login ad_Login = aLoginDao.findByNameAndPwd(uname,passwd);
		
		// 返回数据JSON: {} --> map, [] --> list
		Map<String, Object> map = new LinkedHashMap<>();
		if(null==ad_Login) {
			map.put("success", false);
			map.put("msg", "密码或用户名错误");
		}else {
			map.put("success", true);
			map.put("msg", "验证成功!");
		}
		String json = Jackson.me().toJson(map);
		ResponseUtils.renderJson(rc.response(), json);
	}
}
